/*********************************************************************
Author: Michael Carolin and Joseph Sauber

Dependencies: Projectile.java (not made yet) 

Description: ship object class for constructing and managing both 
the player's ship and enemy ships. Constructor takes cartesian 
coordinates for spawning, as well as a string for the directory
in which the program can find relevant image files for rendering.

*********************************************************************/


public class Ship {

	// instance variables
	double xCor, yCor;	// current cartesian-grid coordinates
	int numLives, upgradeLevel;	 
	double velX, velY;
	String images; 
	boolean isHooked, hookFired, powered;

	// player and enemy ship constructor 
	public Ship (double x, double y, String imageDirectory) {
		xCor = x;
		yCor = y;
		numLives = 3;
		velX, velY = 0;
		images = imageDirectory;
		upgradeLevel = 1;	
	}

	// engage laser animation and object
	public void fireLaser() {
		// placeholder; future method for finding right image
		String laserImage = "";
		Projectile beam = new Projectile(laserImage);
		boolean collision = false;
		while (!collision) {
			/*recommend not having the ship worry about the beam trajectory and suggest moving code to the ShipBeam Class*/
			beam.move();
			/* placeholder for several loops through each object arraylist; perhaps make this a static method that is always running in
			main game file and checks ALL objects against each other.
			Otherwise, we need the object arrays within the scope of 
			this class file.
			*/
			for (Object object : frameObjects) {
				// checks if any pixel in object is same as beam
				if ( beam.collidesWith(object) ) { 	
					/*
					Place a collision method here that takes
					two objects and has them interact in a
					predefined way. E.g. laser degrades 
					large asteroid, destroys alien, removes
					shield from searcher, etc.
					*/
					collision = true;
			}
			// in main method for game, need to delete any object that leaves 
			// window bounds
		}
	}

	public fireMissile() {
		if (upgradeLevel >= 2) {}
	}

	public void turnLeft() {}

	public void turnRight() {}

	// 180-degree turn (down arrow for player)
	public void turnAround() {}

	public void fireHook() {
		if (!hookFired) {
			hookFired = true;
		}
	}

	public void lockHook() {
		if (hookFired && !isHooked) {}
	}

	public void releaseHook() {
		if (isHooked) {}
	} 

	public void engageMining() {
		if (isHooked) {}
	}

	public void accelerate() {}

	// potential game mechanic in which power turns off for stealth
	public void switchPower() {}

	// only call if current ship has >= 1 lives left
	public Ship respawn(Ship justDied) {
		Ship reborn = new Ship(justDied.xCor, justDied.yCor, justDied.images);
		reborn.numLives = --justDied.numLives;
		// question: keep upgrade level or no?
		// answer: possibly, but I think respawning should be moved into the GameControl class
		// since this may cause problems down the road.
	}
}

